#!/usr/bin/env python
# -*- coding: utf-8 -*-

import functools
from flask import (
    g,
    jsonify
)


class RequireAdmin(object):
    def __call__(self, method):
        @functools.wraps(method)
        def wrapper(*args, **kwargs):
            if not g.user:
                return jsonify(dict(code=403, message=u'Not Login'))
            return method(*args, **kwargs)
        return wrapper

require_admin_login = RequireAdmin()
